package com.alex.config;

import com.alex.service.StatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
@Endpoint(id = "my-endpoint")
public class MyEndpoint {

    @Autowired
    private StatusService statusService;

    @ReadOperation
    public Map<String, Object> endpoint() {
        Map<String, Object> map = new HashMap<String, Object>(16);
        map.put("status", statusService.getStatus() == null ? "Y" : statusService.getStatus());
        return map;
    }
}
